<?php require_once('../Connections/mlu.php');
mysql_select_db($database_mlu, $mlu); 

$query_Recordset1riclibri = "select datares,count(depositati.idmlu) as conto,count(carrelli.idmlu) as libri_venduti,round(sum(prezzo)/2,2) as prezzo_meeting,
round(sum(if(depositati.idmlu=carrelli.idmlu,prezzo,0))/2,2) as prezzo_venduti
from depositati
left join carrelli using(idmlu)
where datares>0
group by datares";
 $Result1 = mysql_query($query_Recordset1riclibri, $mlu) or die(mysql_error());
 $tot=mysql_num_rows($Result1); ?>
<h1>MOVIMENTO LIBRI IN RESTITUZIONE</h1>
<table border="1">
  <tr>
  <th>data</th>
  <th>libri restituiti</th>
  <th>libri venduti</th>
  <th>prezzo meeting</th>
  <th>prezzo venduti</th>
  
  </tr>
  <?php while ($row_Recordset1 = mysql_fetch_assoc($Result1))
  { ?>
	
    <tr>  
		<td><?php echo $row_Recordset1['datares']; ?></td>
		<td><?php echo $row_Recordset1['conto']; ?></td>
		<td><?php echo $row_Recordset1['libri_venduti']; ?></td>
        <td><?php echo $row_Recordset1['prezzo_meeting']; ?></td>
        <td><?php echo $row_Recordset1['prezzo_venduti']; ?></td>
  </tr>
  
  <?php }?>
  </table>
  
  
  <?php $query_Recordset1riclibri = "select count(*) as conto from depositati join carrelli using (idmlu) where datares>0";
 $Result1 = mysql_query($query_Recordset1riclibri, $mlu) or die(mysql_error());
 $tot=mysql_num_rows($Result1);
 $row_Recordset1 = mysql_fetch_assoc($Result1); ?>
 <h1>totale libri venduti in restituzione: <?php echo $row_Recordset1['conto']; ?></h1>
 
 <?php $query_Recordset1riclibri = "select round(sum(prezzo)/2,2) as totale from depositati join carrelli using (idmlu) where datares>0";
 $Result1 = mysql_query($query_Recordset1riclibri, $mlu) or die(mysql_error());
 $tot=mysql_num_rows($Result1);
 $row_Recordset1 = mysql_fetch_assoc($Result1);
 $ven=$row_Recordset1['totale']; ?>
 <h1>prezzo totale: <?php echo $ven; ?></h1>
